package com.hotel.web.controller;

import javax.faces.model.SelectItem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hotel.main.entity.Client;
import com.hotel.main.entity.enums.Gender;
import com.hotel.main.service.IClientService;

@Controller("clientControllerBean")
@Scope(value = "request")
public class ClientControllerBean {

	@Autowired
	private IClientService clientService;
	private Client currentClient = new Client();
	private SelectItem[] genderValues;
	
	public void signupClient() {
		clientService.signup(currentClient);
	}
	
	public void addInfo()
	{
		clientService.addInfo(currentClient);
	}
	
	/*
	 *  Setters and getters
	 */
	public void setCurrentClient(Client currentClient) {
		this.currentClient = currentClient;
	}

	public Client getCurrentClient() {
		return currentClient;
	}
	
	public SelectItem[] getGenderValues()
	{
		SelectItem[] items = new SelectItem[Gender.values().length];
        int i = 0;
        for(Gender gender: Gender.values()) 
        {
            items[i++] = new SelectItem(gender, gender.getLabel());
        }
        return items;
	}
	
}
